package impl;

import dao.SaveFile;

import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;

public class SaveFileTxt implements SaveFile {
    private String sourceName;
    public SaveFileTxt(String sourceName, String sourceText){
        this.sourceName=sourceName;
        File file = new File("D:\\onlineDemo\\" + sourceName + ".txt");
        FileWriter fw = null;
        try {
            fw = new FileWriter(file.getAbsoluteFile());
        } catch (IOException e) {
            e.printStackTrace();
        }
        BufferedWriter bw = new BufferedWriter(fw);
        try {
            bw.write(sourceText);
            bw.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
